package com.zackeus.mvvm.binding;

import androidx.databinding.InverseMethod;

import com.zackeus.common.utils.StringUtils;

/**
 * databinding 数据转换器
 * @name: Converts
 * @author: zz
 * @date: 2022/9/22
 */
public class Converters extends androidx.databinding.adapters.Converters {

    public static long stringToLong(String s) {
        if (StringUtils.isBlank(s)) {
            return 0;
        }
        return Long.parseLong(s);
    }

    @InverseMethod(value = "stringToLong")
    public static String longToString(long v) {
        return String.valueOf(v);
    }
}
